<div class="box white_bg">
<? if (isset($this->viewParams['mode']) && $this->viewParams['mode'] === 'new') :?>
	   <div class="chitiet_bar">
	        <div class="chitiet_bar_left"></div>
	        <div class="chitiet_bar_right">New <?=$this->viewParams['nodeTypeInfo']['type'] ?></div>
	   </div>
<?endif ?>
<?if(isset($this->viewParams['successMessage'])) :?>
<div class="successMessage"> <?=$this->viewParams['successMessage']?> </div>
<?endif ?>

<?if(isset($this->viewParams['errorMessage'])) :?>
<div class="errorMessage"> <?=$this->viewParams['errorMessage']?> </div>
<?endif ?>

<br/><br/>
<form id="new_<?=$this->viewParams['type']?> action="<?=$this->viewParams['form']->getAction() ?>" method="<?=$this->viewParams['form']->getMethod() ?>">
<table>
<? if ($this->viewParams['nodeTypeInfo']['has_title']) :?><!--  -->
<tr>
<td width="15%">
Title: 
</td>
<td><?=$this->viewParams['form']->title ?></td>
</tr>
<?endif ?>

<? if ($this->viewParams['nodeTypeInfo']['needs_translation']) :?><!--  -->
<tr>
<td width="15%">
Language: 
</td>
<td><?=$this->viewParams['form']->language ?></td>
</tr>

<?endif ?>

<? if (isset($this->viewParams['form']->category)) :?>
<tr>
<td width="15%">
Category: 
</td>
<td>


 <?=$this->viewParams['form']->category ?>
<? if (isset($this->viewParams['nodeTypeInfo']['category_creatable']) && $this->viewParams['nodeTypeInfo']['category_creatable']) :?>
	 <a href="javascript:void();" class="create-new-category">Create a new category</a>
	<span class="new-category-span" style="display:none">
	<input type="text" id="category-name" style="width:100px"/> 
	<input type="button" value="submit" id="new-category-btn"/>
	</span>
	<script type="text/javascript">
		$(function() {
			$("a.create-new-category").click(function(){
				$("span.new-category-span").toggle();	
			})
			
			$("#new-category-btn").click(function(){
				name = $("#category-name").val();
				if (name == '')
				{
					alert("Category name cannot be empty");
					return false;
				}
				else
					$.getJSON("<?=$this->hvnUrl(array(
								"module" => "node",
								"controller" => "ajax",
								"action" => "create-new-user-category"
								), "generic"); ?>", 
						{ "category-name": name, 
						  "node-type" : "<?=$this->viewParams['nodeTypeInfo']['type']?>"}, 
						function(json){
							if (json.success)
							{
								$('<option/>').val(json.id).text("-- " + name).appendTo($('#category'));
								$("#category").val(json.id);
								$("span.new-category-span").hide();
							}
							else
							{
								if (json.errorCode == "exists")
								{
									$("#category").val(json.id);
									$("span.new-category-span").hide();
								}
								alert(json.errorMessage);
							}
						}
					);
			});
		});
		
	</script>
	
	
<?endif ?>
<?endif ?>
</td>
</tr>

<? if ($this->viewParams['nodeTypeInfo']['has_body']) :?>
<tr>
<td width="15%" colspan="2">
Body: <br/>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$this->viewParams['form']->body ?>
 </td>
 </tr>
<?endif ?>

<? if ($this->viewParams['nodeTypeInfo']['has_keywords']) :?>
<tr>
<td width="15%">
Keywords:
</td>
<td>
 <?=$this->viewParams['form']->keywords ?>
 </td>
 </tr>
<?endif ?>

<?
	$sess = new Zend_Session_Namespace(CLU_NS);
	if (strpos ($sess->userPermissions, 'set status ' . $this->viewParams['type']))
:?>

<tr>
<td width="15%">
Status:
</td>
<td>
<?=$this->viewParams['form']->status ?>
</td>
</tr>
<?endif ?>

</table>
<? 
if (isset($this->viewParams['nodeTypeInfo']['requires_captcha']) && $this->viewParams['mode'] === 'new' && 
	(strpos ($sess->userPermissions, 'set status '. $this->viewParams['type']) === false)) 
:?>
<br/>
<script src="/public/library/hvn/captcha.redraw.js" type="text/javascript"></script>
	<div> 
	<?=$this->viewParams['form']->captcha_newplace ?>
	<a href="javascript:void()" class="redraw"> <?=t(22) ?> </a>
	</div>
<?endif ?>

<br/>

<?=$this->viewParams['form']->submit ?>

</form>
<script>
$(function() {
    val = $("#title").html();
    $("#title").html(val.replace(/xxx/g, "\n"));
});
</script>
</div>
